import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 05 - 10
 * Time: 16:08
 */
public class Main_ {
    public User login(){
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入用户名：");
        String name = scanner.nextLine();
        System.out.println("请选择身份：0-->管理员 1-->读者");
        int chose = scanner.nextInt();
        if(chose == 0){
            return new AdminUser(name);
        }else {
            return new NormalUser(name);
        }
    }
    public static void main(String[] args) {
        BookList bookList = new BookList();
        Main_ main = new Main_();
        while (true){
            User user = main.login();//向上转型
            int choice = user.menu();//动态绑定
            user.doOperate(choice, bookList);
        }
    }
}
